﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManagerUser.aspx.cs" Inherits="ShowroomMobile.ManagerUser"
    MasterPageFile="~/AdminSite.Master" Theme="tbmobile" %>

<%@ Register Assembly="ShowroomMobile" Namespace="jNET.Controls" TagPrefix="cc" %>
<asp:Content runat="server" ID="cManagerUser" ContentPlaceHolderID="body">
    <style>
        #ifrm
        {
            width: 100%;
            height: 250px;
            border: 0px;
        }
    </style>
    <div id="jqwin">
    </div>
    <asp:UpdatePanel runat="server" ID="upUser">
        <ContentTemplate>
            <script type="text/javascript">
                function AddUser() {
                    var d = $('#jqwin').html('<iframe id="ifrm" src="<%= ShowroomMobile.Utilities.Root %>/UpdateUser.aspx"></iframe>');
                    d.dialog({ width: 550, height: 300, title: 'Add New User', modal: true,
                        close: function (event, ui) {
                            var btnReloadGridUser = document.getElementById("<%= btnReloadGridUser.ClientID %>");
                            btnReloadGridUser.click();
                        }
                    });
                    return true;
                }
                function EditUser(id) {
                    var d = $('#jqwin').html('<iframe id="ifrm" src="<%= ShowroomMobile.Utilities.Root %>/UpdateUser.aspx?id=' + id + '"></iframe>');
                    d.dialog({ width: 550, height: 300, title: 'Edit User', modal: true,
                        close: function (event, ui) {
                            var btnReloadGridUser = document.getElementById("<%= btnReloadGridUser.ClientID %>");
                            btnReloadGridUser.click();
                        }
                    });
                    return true;
                }

                function closeIframe() {
                    $('#jqwin').dialog('close');
                    return false;
                } 
            </script>
            <a onclick="AddUser()" href="#">
                <img src="images/add.png" alt="Add New User" />
                Add New User </a>
            <div style='height: 10px'>
                &nbsp;</div>
            <asp:Panel ID="Panel1" runat="server" DefaultButton="btnSearchUser" Style="padding: 5px 0px 5px 0px;">
                <asp:TextBox runat="server" ID="txtSearchUser" placeholder="Search" Width="200px"
                    class="txt" />&nbsp;<asp:Button runat="server" ID="btnSearchUser" Text="Search" OnClick="btnSearchUser_Click" />
            </asp:Panel>
            <cc:CustomGrid Width="100%" AllowRowSelect="false" GridLines="None" CssClass="clientGrid"
                AllowCustomPaging="true" OnItemCommand="gridUser_ItemCommand" ID="gridUser" runat="server"
                AutoGenerateColumns="false" AllowPaging="true" PageSize="10" OnPageIndexChanged="gridUser_PageIndexChanged"
                DataKeyField="ID" OnNeedDataSource="gridUser_OnNeedDataSource" PagerStyle-Mode="NumericPages">
                <Columns>
                    <cc:CustomTemplateField HeaderText="User Name" ItemStyle-Width="30%" HeaderStyle-Width="35%">
                        <ItemTemplate>
                            <%# Eval("UserName") %>
                        </ItemTemplate>
                    </cc:CustomTemplateField>
                    <cc:CustomTemplateField HeaderText="Full Name" ItemStyle-Width="45%" HeaderStyle-Width="45%">
                        <ItemTemplate>
                            <%# Eval("FullName")%>
                        </ItemTemplate>
                    </cc:CustomTemplateField>
                    <cc:CustomTemplateField HeaderText="Admin Master" ItemStyle-Width="20px" HeaderStyle-Width="20px"
                        ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                        <ItemTemplate>
                            <asp:CheckBox ID='chkActive' Checked='<%# (bool)Eval("MasterAdmin") %>' Enabled="false"
                                runat="server" />
                        </ItemTemplate>
                    </cc:CustomTemplateField>
                    <cc:CustomTemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                        ItemStyle-Width="10px" HeaderStyle-Width="10px" HeaderText="Edit">
                        <ItemTemplate>
                            <a onclick='EditUser(<%# Eval("ID") %>)' href="#">
                                <asp:Image ImageUrl="~/images/edit.png" runat="server" ID="imbEdit" />
                            </a>
                        </ItemTemplate>
                    </cc:CustomTemplateField>
                    <cc:CustomTemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                        ItemStyle-Width="10px" HeaderStyle-Width="10px" HeaderText="">
                        <ItemTemplate>
                            <asp:ImageButton ID="btnDelete" runat="server" ToolTip="Delete" ImageUrl="~/images/delete.png"
                                OnClientClick='return confirm("Are you sure to delete this item?");' CommandName="Delete"
                                CommandArgument='<%# Eval("ID") %>' />
                        </ItemTemplate>
                        <HeaderTemplate>
                            <asp:LinkButton ID="btnDeleteAll" runat="server" ToolTip="Delete All" OnClientClick='return confirm("Are you sure to delete all item(s)?");'
                                CommandName="DeleteAll">
                                <asp:Image ImageUrl="~/images/delete.png" runat="server" ID="imgDeleteAll" />
                            </asp:LinkButton>
                        </HeaderTemplate>
                    </cc:CustomTemplateField>
                </Columns>
            </cc:CustomGrid>
            <asp:Button runat="server" ID="btnReloadGridUser" Style="display: none" 
                    OnClick="btnReloadGridUser_Click" />
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
